#ifndef TRACKED_OBJECT_HXX
#define TRACKED_OBJECT_HXX

#include <QMetaType>
#include <map>
#include <utility>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include "Shape.hxx"

class TrackedObject
{
public:
	TrackedObject();
	inline void setObjectId(int id) { _objectId = id; }
	inline int getObjectId() { return _objectId; }

    inline void setClassIndex(int index) { _classIndex = index; }
    inline int getClassIndex() { return _classIndex; }

	inline void setStartFrameIndex(int index) { _startFrameIndex = index; }
	inline const int getStartFrameIndex() const  { return _startFrameIndex; }

	inline void setEndFrameIndex(int index) { _endFrameIndex = index; }
	inline const int getEndFrameIndex() const { return _endFrameIndex; }

	inline int getFrameCounts() { return _endFrameIndex - _startFrameIndex + 1; }

    //void pushRect(int frameIndex, cv::Rect2d rect);
    void eraseRect(int frameIndex);

    void pushShape(int frameIndex, Shape* shape);
    void eraseShape(int frameIndex);

    cv::Rect2d getRect(int frameIndex);
	Shape* getShape(int frameIndex);

	inline void setTemplateBox(cv::Rect2d rect) { _templateBox = rect; }
	inline cv::Rect2d getTemplateBox() { return _templateBox; }

	inline void select() { _isSelected = true; }
	inline void deselect() { _isSelected = false; }
	inline bool isSelected() { return _isSelected; }

	inline bool isVisible() { return _visible; }
	inline void setVisible(bool visible) { _visible = visible; }

private:
	int _objectId;
	int _startFrameIndex;
	int _endFrameIndex;
    int _classIndex;

	bool _isSelected;

	bool _visible;

    //std::map<int,cv::Rect2d> _boxes;
    std::map<int,Shape*> _boxes;
	cv::Rect2d _templateBox;
};

Q_DECLARE_METATYPE(TrackedObject*)

#endif
